< previous page page_452 next page >

Page 452
Using the Windows API in Visual Basic
The Windows API is sometimes called the Win32 API, in reference to the use of 32-bit functions. The 16-bit API was used in Windows 3.11 and earlier versions of Visual Basic. Although Windows 95 and NT provide backward compatibility for applications compiled using 16-bit calls, you cannot declare a 16-bit API function in Visual Basic 6.0. This point is important to remember when you're upgrading old projects.
Using the API Viewer
Windows API function declarations and the constants and types used with them are listed in the file WIN32API.TXT. This file is installed in the WINAPI subdirectory of the Visual Basic program directory. To use an API function in your program, simply copy and paste the information you need from this file. Comments are also included in the file to help you make some sense of the function's purpose.
Visual Basic comes with a tool called the API Text Viewer, which is designed to make adding API functions quick. The API Text Viewer, shown in Figure 20.2, organizes the Windows API functions alphabetically and allows you to copy multiple API functions to the Windows Clipboard.
To use the API Viewer, click the API Text Viewer icon in your Visual Basic program group. Next, from the File menu, choose Load Text File and select WIN32API.TXT. (Note that you are given the option of converting WIN32API.TXT to a database file for faster loading.) After the API Viewer parses the text file, you are presented with a list of available API declarations in the Available Items box.
0452-01.jpg
Figure 20.2
The API Viewer lets you copy any combination of
types, declares, and constants to the Windows Clipboard.

 
< previous page page_452 next page >